package com.mask.sca.system.controller;

import com.mask.sca.system.entity.Post;
import com.mask.sca.system.service.PostService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;

@RestController
@RequestMapping("/system/post")
public class PostController {
    @Autowired
    private PostService postService;

    @GetMapping("/list")
    public List<Post> list() {
        return postService.list();
    }

    @GetMapping("/{id}")
    public Post get(@PathVariable Long id) {
        return postService.getById(id);
    }

    @PostMapping("/add")
    public boolean add(@RequestBody Post post) {
        return postService.save(post);
    }

    @PutMapping("/update")
    public boolean update(@RequestBody Post post) {
        return postService.updateById(post);
    }

    @DeleteMapping("/delete/{id}")
    public boolean delete(@PathVariable Long id) {
        return postService.removeById(id);
    }
} 